
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>谈谈你理解的类加载器 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>谈谈你理解的类加载器 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Java类加载器的核心职责是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">类加载器负责将类的字节码加载到JVM中，并生成对应的Class对象。它是Java虚拟机的一个核心组件，负责在Java程序运行时动态加载类文件。</div>
          </div>
          <div class="card-source">来源: 类加载器中的概念</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">什么是双亲委派模型？请描述其工作流程。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">双亲委派模型是类加载器工作的一个重要原则。当一个类加载器接收到加载类的请求时，它会首先将请求委派给其父类加载器进行加载，只有在父类加载器无法加载时，才由自己来加载。</div>
          </div>
          <div class="card-source">来源: 类加载器中的概念</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">采用双亲委派模型主要有哪些好处？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">双亲委派模型的好处是避免类的重复加载，从而保证了类的唯一性；同时，它也确保了Java核心类库的安全性和稳定性。</div>
          </div>
          <div class="card-source">来源: 双亲委派模型</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">一个完整的类加载过程包含哪三个主要阶段？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">类加载器的加载过程包括加载、连接和初始化三个阶段。其中，连接阶段又包括验证、准备和解析三个步骤。</div>
          </div>
          <div class="card-source">来源: 工作原理</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">JVM中内置的三个主要类加载器分别是什么，它们各自负责加载什么内容？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">1. 启动类加载器 (Bootstrap ClassLoader): 负责加载Java核心类库。<br>2. 扩展类加载器 (Extension ClassLoader): 负责加载JRE扩展库。<br>3. 应用程序类加载器 (Application ClassLoader): 负责加载应用程序classpath下的类文件。</div>
          </div>
          <div class="card-source">来源: 常见的类加载器</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">如果想实现一个自定义类加载器，通常需要继承哪个类并覆盖哪个方法？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">自定义类加载器通常需要继承自`ClassLoader`类，并覆盖其中的`findClass()`方法来实现自定义的类加载逻辑。</div>
          </div>
          <div class="card-source">来源: 自定义类加载器</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">在什么场景下需要使用自定义类加载器？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">自定义类加载器主要用于满足一些特定的加载需求，例如实现热部署、插件化功能，或者用于加载加密的类文件、从非标准位置加载类，以及实现类的保护等需求。</div>
          </div>
          <div class="card-source">来源: 自定义类加载器</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">文档中提到了哪两种破坏双亲委派模型的方式？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">可以通过两种方式来破坏双亲委派模型：第一种是重写ClassLoader的`loadClass`方法；第二种是使用`Thread.currentThread().setContextClassLoader`方法。</div>
          </div>
          <div class="card-source">来源: 破坏双亲委派模型</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">为什么像Tomcat这样的Web服务器需要破坏双亲委派模型？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Tomcat破坏双亲委派模型是为了实现Web应用程序之间的类隔离。每个Web应用都有自己的类加载器，它会优先加载本应用内的类，而不是先委派给父加载器，这样可以有效防止不同应用间的类冲突和污染。</div>
          </div>
          <div class="card-source">来源: 破坏双亲委派模型</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
